@echo off
set /p fileName=Enter IFC fileName:

md .\convert\%fileName%
@echo ********************* Step 1 of 4 [IFC--DAE] *********************
.\IfcConvert-v0.6.0\IfcConvert.exe --use-element-guids .\%fileName%.ifc .\convert\%fileName%\%fileName%.dae
@REM --exclude=entities IfcOpeningElement

set result=%ERRORLEVEL%

if %result%==0 ( 
    @echo ********************* Step 2 of 4 [DAE--GLTF] *********************
    .\COLLADA2GLTF-v2.1.5\COLLADA2GLTF-bin.exe -i .\convert\%fileName%\%fileName%.dae -o .\convert\%fileName%\%fileName%.gltf

    @echo ********************* Step 3 of 4 [GLTF--XKT] *********************
    node .\xeokit-gltf-to-xkt-0.0.61\gltf2xkt.js -s .\convert\%fileName%\%fileName%.gltf -o .\convert\%fileName%\%fileName%.v6.xkt -f 6

    @echo ********************* Step 4 of 4 [METADATA] *********************
    .\xeokit-metadata-attrs\xeokit-metadata-attrs.exe .\%fileName%.ifc .\convert\%fileName%\%fileName%.json

    @REM del .\%fileName%.ifc
    @REM del .\convert\%fileName%\%fileName%.dae
    @REM del .\convert\%fileName%\%fileName%.gltf
    @echo success!
    @echo off

    pause;
) else (
    @echo An error occurred. Please try again later!
    echo off

    pause;
)
